<template>
	<div id="admin">
		<el-container v-if="routerArr.indexOf($route.path) == -1">
			<!-- 侧边栏    -->
			<div class="silder-bar-wrap">
				<el-menu
					:default-active="defaultActive"
					class="el-menu-vertical-demo"
					:collapse="isCollapse"
					background-color="#545c64"
					text-color="#fff"
					active-text-color="#ffd04b"
					router
					unique-opened
					style="border-right: none;">
					<div class="logo-box">
						<img src="~/assets/img/head_logo.png" class="logo" />
					</div>
					<template v-for="(item,index) in newRouter">
						<el-menu-item v-if="item.level1" :index="item.path" :key="index">
							<template slot="title">
								<i :class="item.icon"></i>
								<span slot="title">{{item.text}}</span>
							</template>
						</el-menu-item>
						<el-submenu v-if="!item.level1" :index="index+''" :key="index">
							<template slot="title">
								<i :class="item.icon"></i>
								<span slot="title">{{item.text}}</span>
							</template>
							<template v-for="(item2,index2) in item.routers">

								<template v-if='item2.text=="待接订单"' >
									<el-menu-item index="/admin/order/pendingDisposal" :key="index2"  @click.native="refresh(item2)">
										<span slot="title">
											<el-badge :value="getRoleInfo"  class="item">
												<span>{{item2.text}}</span>
											</el-badge>
										</span>
									</el-menu-item>
								</template>

								<el-submenu v-else-if="item2.childrens" :key="index2" index='' >
									<template slot="title">
										<i :class="item2.icon"></i>
										<span slot="title">{{item2.text}}</span>
									</template>
									<template v-for="(childrensItem, index3) in item2.childrens">
										<el-menu-item v-if="childrensItem.role_id.indexOf($store.state.user.role_id) != -1" :key="index3" :index="childrensItem.path" @click.native="refresh(childrensItem)">
											<template slot="title" v-if='childrensItem.text == "专利列表"'>
													<span slot="title">
														<el-badge :value="getUnbind"  class="item">
															<span>{{childrensItem.text}}</span>
														</el-badge>
													</span>
											</template>
											<template slot="title" v-else-if='childrensItem.text == "软著列表"'>
													<span slot="title">
														<el-badge :value="getSoftTotal"  class="item">
															<span>{{childrensItem.text}}</span>
														</el-badge>
													</span>
											</template>
										</el-menu-item>
									</template>
								</el-submenu>

								<template v-else>
									<el-menu-item
										v-if="item2.role_id.indexOf($store.state.user.role_id) != -1"
										:key="index2"
										:index="item2.path"
										@click.native="refresh(item2)">
										<!-- 代理人 -->
										<!-- <template slot="title" v-if='item2.text == "专利列表"'>

										</template> -->
										<template slot="title" v-if='item2.text == "我的订单"'>
												<span slot="title">
													<el-badge :value="getMyOrder"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>
										<template slot="title" v-else-if='item2.text == "我的答复"'>
												<span slot="title">
													<el-badge :value="getMyReply"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>

										<template slot="title" v-else-if='item2.text == "我的结算"'>
												<span slot="title">
													<el-badge :value="getMonTotal"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>
										<!-- 自提列表 -->
										<template slot="title" v-else-if='item2.text == "自提列表"'>
												<span slot="title">
													<el-badge :value="getAgentOrderCount"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>
										<!-- 我的专利 -->
										<template slot="title" v-else-if='item2.text == "我的专利"'>
												<span slot="title">
													<el-badge :value="getPatentCount"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>

										<!-- 管理员出师申请列表 -->
										<template slot="title" v-else-if='item2.path == "/admin/users/graduation"'>
											<span slot="title">
												<el-badge :value="getFinalApply"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<!-- 代理人预注册 -->
										<template slot="title" v-else-if='item2.path == "/admin/users/agent-review"'>
											<span slot="title">
												<el-badge :value="getPreregistration"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>

										<!-- 徒弟列表 -->
										<template slot="title" v-else-if='item2.text == "徒弟列表"'>
											<span slot="title">
												<el-badge :value="getStudentsApply"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>

										<!-- 代理人出师申请列表 -->

										<!-- <template slot="title" v-else-if='item2.path == "/admin/students/apply"'>
											<span slot="title">
												<el-badge :value="getStudentsApply"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template> -->

										<!-- <template v-if="$store.state.user.is_teacher == 1">

										</template> -->
										<template slot="title" v-else-if='item2.text == "审核列表"'>
												<span slot="title">
													<el-badge :value="getAuditedNum"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>


										<!-- 流程 管理员-->

										<template slot="title" v-else-if='item2.text == "国知局前订单"'>
												<span slot="title">
													<el-badge :value="getTimeOut"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>

										<template slot="title" v-else-if='item2.path == "/admin/order/formatReview"'>
												<span slot="title">
													<el-badge :value="getFinishFileFormatAudit"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>
										<template slot="title" v-else-if='item2.text == "国知局后订单"'>
												<span slot="title">
													<el-badge :value="getWaitSubmitTotal"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>
										<template slot="title" v-else-if='item2.text == "答复列表"'>
												<span slot="title">
													<el-badge :value="getReplyTotal"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>

										<template slot="title" v-else-if='item2.text == "未开票列表"'>
												<span slot="title">
													<el-badge :value="getCanInvoiceTotal"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>
										<template slot="title" v-else-if='item2.text == "可核款列表" && $store.state.user.role_id != 4'>
												<span slot="title">
													<el-badge :value="getCanNuclearMoneyTotal"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>
										<template slot="title" v-else-if='item2.text == "退款列表"'>
												<span slot="title">
													<el-badge :value="getCan_refund_total"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>

										<!-- <template slot="title" v-else-if='item2.text == "代理人提现审核"'>
											<span slot="title">
												<el-badge :value="getDrawing_agent_check"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<template slot="title" v-else-if='item2.text == "用户提现审核"'>
											<span slot="title">
												<el-badge :value="getDrawing_consumer_check "  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template> -->
										<template slot="title" v-else-if='item2.text == "提现审核列表"'>
											<span slot="title">
												<el-badge :value="getDrawing_consumer_check + getDrawing_agent_check "  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<template slot="title" v-else-if='item2.text == "活动列表"'>
											<span slot="title">
												<el-badge :value="getActivity_check"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<template slot="title" v-else-if='item2.text == "扣款申诉"'>
											<span slot="title">
												<el-badge :value="getAppealCount"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<template slot="title" v-else-if='item2.path == "/admin/complaint/appealReview"'>
											<span slot="title">
												<el-badge :value="getAgent_grades_appeal"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<template slot="title" v-else-if='item2.path == "/admin/complaint/withdrawImg"'>
											<span slot="title">
												<el-badge :value="getRevokePayImgCount"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<!-- 反馈意见审核 -->
										<template slot="title" v-else-if='item2.path == "/admin/complaint/opinionAudit"'>
											<span slot="title">
												<el-badge :value="getopinionCollectAudit"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>

										<template slot="title" v-else-if='item2.text == "已开票列表"'>
												<span slot="title">
													<el-badge :value="getInvoiced_total"  class="item">
														<span>{{item2.text}}</span>
													</el-badge>
												</span>
										</template>

										<!-- 审核员 -->
										<template slot="title" v-else-if='item2.text == "待审核列表"'>
											<span slot="title">
												<el-badge :value="getVerifyTotal"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<template slot="title" v-else-if='item2.text == "返修列表"'>
											<span slot="title">
												<el-badge :value="getModifyTotal"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>
										<template slot="title" v-else-if='item2.text == "待回复列表"'>
											<span slot="title">
												<el-badge :value="getModify_total_message"  class="item">
													<span>{{item2.text}}</span>
												</el-badge>
											</span>
										</template>

										<template slot="title" v-else>
												<span slot="title">{{item2.text}}</span>
										</template>

									</el-menu-item>
								</template>

							</template>
						</el-submenu>

					</template>
					<!-- 个人中心 -->
					<el-submenu index="">
						<template slot="title">
							<i class="el-icon-setting"></i>
							<span slot="title">个人中心</span>
						</template>
						<el-menu-item index="/admin/myNews/notice" v-if="/^(2|3|4|7)$/.test($store.state.user.role_id)">
							<template slot="title">
								<el-badge :value="getNoRead"  class="item">
									<span>我的消息</span>
								</el-badge>
							</template>
						</el-menu-item>
						<el-menu-item @click="apply" index="" v-if="$store.state.user.role_id == 2 && $store.state.user.is_teacher == 2">
							<span slot="title">
								<span v-if='$store.state.roleInfo.is_adopt == "未申请"'>申请出师</span>
								<el-badge
									v-else
									is-dot
									class="teacher_tips"
									:type='is_adopt'
									>申请出师</el-badge>
							</span>
						</el-menu-item>
						<el-menu-item index="/admin/personalCenter/myPurse" v-if="$store.state.user.role_id == 2 && $store.state.user.vip > 0">
							<template slot="title">
								<span slot="title">我的钱包</span>
							</template>
						</el-menu-item>
						<el-menu-item index="/admin/personalCenter/dstribution" v-if="$store.state.user.role_id == 2">
							<template slot="title">
								<span slot="title">我的推荐</span>
							</template>
						</el-menu-item>
						<!-- <el-menu-item @click="editEmail" index="" v-if="!is_improve">修改资料</el-menu-item> -->
						<el-menu-item @click="editEmail" index="" v-if="!is_improve">修改资料</el-menu-item>
						<el-menu-item @click="editPwd" index="" v-if="!is_improve">修改密码</el-menu-item>
						<el-menu-item @click.native='feedback()' v-if="$store.state.user.role_id == 2">意见反馈</el-menu-item>
						<el-menu-item @click="loginOut" index="">退出</el-menu-item>
					</el-submenu>
					<!-- <el-menu-item index="" @click="openLeaderboard" v-if="$store.state.user.role_id == 2">
						<i class="iconfont icon-paihangbang admin_icon"></i>
						<span slot="title">排行榜</span>
					</el-menu-item> -->
				</el-menu>

				<!-- <div class='rank'>
					<el-button
						@click="openLeaderboard"
						v-if="$store.state.user.role_id == 2"
						icon="iconfont icon-paihangbang admin_icon"
						circle>
					</el-button>
				</div> -->

				<div class="welcome">
					<el-button type="primary"  @click='buyVip' class='buyVip mb20' v-if="$store.state.user.role_id == 2 && $store.state.user.vip == 0" >升级VIP</el-button>
					<!-- <div class="buyVip tc">升级VIP</div> -->
					<div>
						<img :src="smileSvg" alt="">
						<!-- <span v-if="$store.state.user.role_id == 2">欢迎您，{{$store.state.user.nickname}}！</span>
						<span v-else>欢迎您，{{$store.state.user.name}}！</span> -->
						<span>欢迎您，{{$store.state.user.name}}！</span>
					</div>
					<div class="mt10" v-if="$store.state.user.is_teacher == 2 && $store.state.user.role_id == 2 && $store.state.user.teacher" >您的导师：<span class="login-yellow">{{$store.state.user.teacher.name}}</span></div>
				</div>
				<div class="welcome vip" v-if="$store.state.user.vip != 0">
					<!-- <img :src="vipLogo" alt=""> -->
					<i :class="vipLogoClass"></i>
					<span class='font_warning'>{{ $store.state.user.vip | agentVipLeval}}</span>
				</div>

			</div>

			<el-container>
				<!-- 个人中心 -->
				<el-header class="main-heads" style="text-align: right; font-size: 12px;position:relative;background: #fff">
					<div class="fr rank" v-if="$store.state.user.role_id == 2">
						<el-button
							type="text"
							@click="openLeaderboard"
							icon="iconfont icon-paihangbang admin_icon"
							>排行榜</el-button>
					</div>

				</el-header>
				<editEmail ref="emailEdit"></editEmail>
				<editPwd ref="editPwd"></editPwd>
				<rank ref="rank"></rank>
				<feedback ref="feedback"></feedback>
				<!-- 主页面 -->
				<el-main>
					<nuxt-child id="gwm" />
				</el-main>
			</el-container>
		</el-container>
		<nuxt-child v-else />
	</div>
</template>


<script>
	import editEmail from './admin/users/detailPage/editEmail'
	import editPwd from './admin/users/detailPage/editPwd'
	import rank from '~/components/rank'
	import feedback from '~/components/feedback'
	import {
		getRoleInfo
	} from "~/api/user";
	import { getMyInfo } from "~/api/user";
	import smileSvg from '~/assets/img/smile.svg'
	export default {
		data() {
			return {
				vipLogo: '',
				smileSvg: smileSvg,
				circleUrl: require('~/assets/img/3ea6beec64369c2642b92c6726f1epng.png'),
				defaultActive: "", //admin/users
				newRouter: [],
				tempRouters:[
					{
						icon: "el-icon-s-data",
						text: "数据统计",
						role_id: [1, 4, 7],
						role_id: [1, 4, 7],
						routers: [
							{
								path: "/admin/dataSum/agentData",
								text: "代理人统计",
								role_id: [1, 4, 7]
							},
							// {
							// 	path: "/admin/dataSum",
							// 	text: "代理人统计",
							// 	role_id: [1, 4, 7]
							// },
							// {
							// 	path: "/admin/dataSum/finialSum",
							// 	text: "结算统计",
							// 	role_id: [1, 4, 7]
							// },
							// {
							// 	path: "/admin/dataSum/orderSum",
							// 	text: "订单耗时",
							// 	role_id: [1, 4, 7]
							// },
							// {
							// 	path: "/admin/order/sum",
							// 	text: "订单统计",
							// 	role_id: [1, 7],
							// },
							{
								path: "/admin/dataSum/orderStatistics",
								text: "订单统计",
								role_id: [1, 4, 7],
							},
							{
								path: "/admin/dataSum/abnormalData",
								text: "异常数据统计",
								role_id: [1, 4, 7],
							},

						]
					},
					{
						icon: "el-icon-user",
						text: "用户管理",
						role_id: [1, 4, 7],
						routers: [
								{
								path:'/admin/users/agent-review',
								text:'代理人预注册列表',
								role_id: [1, 7],
								is_refresh: true,
							},
							{
								path: "/admin/users/agent",
								text: "代理人列表",
								role_id: [1, 4, 7]
							},
							{
								path: "/admin/users/graduation",
								text: "申请出师列表",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							{
								path: "/admin/users/admin",
								text: "子管理员列表",
								role_id: [1, 7]
							},
							{
								path: "/admin/users/auditor",
								text: "审核员列表",
								role_id: [1, 7]
							},
							{
								path: "/admin/users/processManagement",
								text: "流程人员列表",
								role_id: [1, 7]
							},
							{
								path: "/admin/users/outgoing",
								text: "离职人员列表",
								role_id: [1, 7]
							}
							// {
							// 	path:'/admin/users/permission',
							// 	text:'权限管理',
							// }
						]
					},
					{
						icon: "el-icon-phone",
						path: "/admin/users/userList",
						text: "客户管理",
						role_id: [1, 4, 7],
						level1: true
					},
					{
						icon: "el-icon-s-custom",
						path: "/admin/users/role",
						text: "权限管理",
						role_id: [1, 7],
						level1: true
					},
					{
						icon: "el-icon-tickets",
						text: "订单管理",
						role_id: [1, 2, 4, 7],
						routers: [

							{
								text: "未处理订单",
								role_id: [1, 2, 4, 7],
								childrens: [
									{
										path: "/admin/order/pendingDisposal",
										text: "专利列表",
										role_id: [1, 2, 4, 7],
										is_refresh: true,
									},
									{
										path: "/admin/order/softlist",
										text: "软著列表",
										role_id: [1, 4, 7],
										is_refresh: true,
									},
								]
							},
							{
								path: "/admin/order/inProcessing",
								text: "国知局前订单",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							{
								path: "/admin/order/inProcessing2",
								text: "国知局后订单",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							// {
							// 	path: "/admin/order/processed",
							// 	text: "已结案",
							// 	role_id: [1, 2, 4]
							// },
							{
								path: "/admin/order/answer",
								text: "答复列表",
								role_id: [1, 2, 4, 7],
								is_refresh: true,
							},
							{
								path: "/admin/order/formatReview",
								text: "格式审核",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							{
								path: "/admin/agent-auditor",
								text: "审核列表",
								role_id: [2],
								level1: true,
								is_refresh: true,
							}
						]
					},
					// {
					// 	icon: "el-icon-document",
					// 	text: "外部订单",
					// 	role_id: [2],
					// 	routers: [
					// 		{
					// 			path: "/admin/agentOrder/processing",
					// 			text: "自提列表",
					// 			role_id: [2],
					// 			// is_refresh: true,
					// 		},
					// 		{
					// 			path: "/admin/agentOrder/myPatent",
					// 			text: "我的专利",
					// 			role_id: [2],
					// 			// is_refresh: true,
					// 		},
					// 	]
					// },

					{
						icon: "el-icon-user",
						text: "徒弟管理",
						role_id: [2],
						routers: [{
								path: "/admin/students/list",
								text: "徒弟列表",
								role_id: [2],
								is_refresh: true,
							},
							// {
							// 	path: "/admin/students/apply",
							// 	text: "申请出师列表",
							// 	role_id: [2],
							// 	is_refresh: true,
							// }
						]
					},
					{
						icon: "el-icon-s-ticket",
						text: "发票管理",
						role_id: [1, 4, 7],
						routers: [
							{
								path: "/admin/invoice/check-fee",
								text: "可核款列表",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							{
								path: "/admin/invoice",
								text: "未开票列表",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							{
								path: "/admin/invoice/endInvoice",
								text: "已开票列表",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							{
								path: "/admin/invoice/refunds",
								text: "退款列表",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
						]
					},
					{
						icon: "el-icon-money",
						text: "结算管理",
						role_id: [1, 7],
						routers: [
							// {
							// 	path: "/admin/settlement/alreadySettlement",
							// 	text: "已结算列表",
							// 	role_id: [1, 7]
							// },
							// {
							// 	path: "/admin/settlement/notSettlement",
							// 	text: "未结算列表",
							// 	role_id: [1, 7]
							// },
							// {
							// 	path: "/admin/settlement/auditor",
							// 	text: "奖惩审核",
							// 	role_id: [1]
							// },
							{
								path: "/admin/settlement/awardAndPunishment",
								text: "奖惩审核",
								role_id: [1, 7]
							},
							{
								path: "/admin/settlement/finialSum",
								text: "结算统计",
								role_id: [1, 7]
							},
							{
								path: "/admin/settlement/agent-bank",
								text: "代理人钱包",
								role_id: [1, 7]
							},

						]
					},
					{
						icon: "el-icon-bank-card",
						text: "审核管理",
						role_id: [3],
						routers: [{
								path: "/admin/auditor",
								text: "待审核列表",
								role_id: [3],
								is_refresh: true,
							},
							// {
							// 	path: "/admin/repair",
							// 	text: "返修列表",
							// 	role_id: [3],
							// 	is_refresh: true,
							// }
							{
								path: "/admin/auditor/waitReply",
								text: "待回复列表",
								role_id: [3],
								is_refresh: true,
							}

							// {
							// 	path: "/admin/auditor/notPass",
							// 	text: "未通过列表",
							// 	role_id: [3]
							// },
							// {
							// 	path: "/admin/auditor/passOrder",
							// 	text: "审核通过",
							// 	role_id: [3]
							// }
						]
					},
					{
						icon: "el-icon-coin",
						text: "提现管理",
						role_id: [1, 7],
						routers: [
							// {
							// 	text: "代理人提现审核",
							// 	role_id: [1, 7],
							// 	path: "/admin/withdraw/agentWithdraw",
							// 	is_refresh: true,
							// },
							// {
							// 	text: "用户提现审核",
							// 	role_id: [1, 7],
							// 	path: "/admin/withdraw/userWithdraw",
							// 	is_refresh: true,
							// }
							{
								text: "提现审核列表",
								role_id: [1, 7],
								path: "/admin/withdraw",
								is_refresh: true,
							},
							{
								path: "/admin/settlement/promte",
								text: "提现明细",
								role_id: [1, 7]
							},
						]
					},
					{
						icon: "el-icon-edit-outline",
						text: "活动管理",
						role_id: [1, 7],
						routers: [
							// {
							// 	path: "/admin/activityList/sysConfig",
							// 	text: "系统配置",
							// 	role_id: [1, 7]
							// },
							{
								path: "/admin/activityList/activityConfig",
								text: "活动列表",
								role_id: [1, 7]
							},
							// {
							// 	text: "活动审核",
							// 	role_id: [1],
							// 	path: "/admin/activityList/reviewActivity",
							// 	is_refresh: true,
							// },
							// {
							// 	path: "/admin/settlement/auditor",
							// 	text: "奖惩审核",
							// 	role_id: [1, 7]
							// },
						]
					},
					{
						icon: "el-icon-warning-outline",
						text: "申诉管理",
						role_id: [1, 4, 7],
						routers: [
							{
								text: "评分申诉",
								role_id: [1, 4, 7],
								path: "/admin/complaint/appealReview",
								is_refresh: true,
							},
							{
								path: "/admin/complaint/deductionsAppeal",
								text: "扣款申诉",
								role_id: [1, 4, 7]
							},
							{
								path: "/admin/complaint/opinionAudit",
								text: "反馈意见",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							// {
							// 	path: "/admin/complaint/withdrawImg",
							// 	text: "撤回缴费截图申请",
							// 	role_id: [1, 4, 7]
							// },
						]
					},
					{
						icon: "el-icon-chat-dot-square",
						text: "公告管理",
						role_id: [1, 7],
						path: "/admin/notice",
						level1: true
					},
					// {
					// 	icon: "el-icon-edit-outline",
					// 	text: "系统配置",
					// 	role_id: [1, 7],
					// 	path: "/admin/sysConfig",
					// 	level1: true
					// },

					// {
					//   icon: "el-icon-bank-card",
					//   text: "退款管理",
					//   routers: [
					//     {
					//       path: "未退款",
					//       text: "已退款"
					//     }
					//   ]
					// }
				],
				routers: [
					{
						icon: "el-icon-user",
						text: "用户管理",
						role_id: [1, 4, 7],
						routers: [
							{
								path:'/admin/users/agent-review',
								text:'代理人预注册列表',
								role_id: [1, 7]
							},
							{
								path: "/admin/users/agent",
								text: "代理人列表",
								role_id: [1, 4, 7]
							},
							{
								path: "/admin/users/graduation",
								text: "申请出师列表",
								role_id: [1, 4, 7]
							},
							{
								path: "/admin/users/admin",
								text: "子管理员列表",
								role_id: [1, 7]
							},
							{
								path: "/admin/users/auditor",
								text: "审核员列表",
								role_id: [1, 7]
							},
							{
								path: "/admin/users/processManagement",
								text: "流程人员列表",
								role_id: [1, 7]
							},
							{
								path: "/admin/users/outgoing",
								text: "离职人员列表",
								role_id: [1, 7]
							}
							// {
							// 	path:'/admin/users/permission',
							// 	text:'权限管理',
							// }
						]
					},
					{
						icon: "el-icon-phone",
						path: "/admin/users/userList",
						text: "客户管理",
						is_refresh: true,
						role_id: [1, 4, 7],
						level1: true
					},
					{
						icon: "el-icon-s-custom",
						path: "/admin/users/role",
						text: "权限管理",
						is_refresh: true,
						role_id: [1, 7],
						level1: true
					},
					{
						icon: "el-icon-tickets",
						text: "订单管理",
						role_id: [1, 2, 4, 7],
						routers: [
							{
								text: "未处理订单",
								role_id: [1, 2, 4, 7],
								childrens: [
									{
										path: "/admin/order/pendingDisposal",
										text: "专利列表",
										is_refresh: true,
										role_id: [1, 2, 4, 7],
									},
									{
										path: "/admin/order/softlist",
										text: "软著列表",
										role_id: [1, 4, 7],
										is_refresh: true,
									},
								]
							},
							{
								path: "/admin/order/inProcessing",
								text: "国知局前订单",
								is_refresh: true,
								role_id: [1, 4, 7]
							},
							{
								path: "/admin/order/inProcessing2",
								text: "国知局后订单",
								is_refresh: true,
								role_id: [1, 4, 7]
							},
							{
								path: "/admin/order/myOreder",
								text: "我的订单",
								is_refresh: true,
								role_id: [2]
							},
							{
								path: "/admin/order/answer",
								text: "我的答复",
								is_refresh: true,
								role_id: [2]
							},
							{
								path: "/admin/order/processed",
								text: "我的结算",
								is_refresh: true,
								role_id: [2]
							},

							{
								path: "/admin/order/sum",
								text: "订单统计",
								role_id: [1, 7],
							},
						]
					},
					// {
					// 	icon: "el-icon-document",
					// 	text: "外部订单",
					// 	role_id: [2],
					// 	routers: [
					// 		{
					// 			path: "/admin/agentOrder/processing",
					// 			text: "自提列表",
					// 			role_id: [2],
					// 			// is_refresh: true,
					// 		},
					// 		{
					// 			path: "/admin/agentOrder/myPatent",
					// 			text: "我的专利",
					// 			role_id: [2],
					// 			// is_refresh: true,
					// 		},
					// 	]
					// },
					{
						icon: "el-icon-user",
						text: "徒弟管理",
						role_id: [2],
						routers: [{
								path: "/admin/students/list",
								text: "徒弟列表",
								role_id: [2],
								is_refresh: true,
							},
							{
								path: "/admin/order/auditor",
								text: "审核列表",
								role_id: [2],
							},
							// {
							// 	path: "/admin/students/apply",
							// 	text: "申请出师列表",
							// 	role_id: [2],
							// 	is_refresh: true,
							// }
						]
					},
					{
						icon: "el-icon-s-ticket",
						text: "发票管理",
						role_id: [1, 4, 7],
						routers: [
							{
								path: "/admin/invoice/check-fee",
								text: "可核款列表",
								role_id: [1, 4, 7],
								is_refresh: true,
							},
							{
								path: "/admin/invoice",
								text: "未开票列表",
								role_id: [1, 4, 7],
								is_refresh: true,
							},{
								path: "/admin/invoice/endInvoice",
								text: "已开票列表",
								role_id: [1, 4, 7],
								is_refresh: true,
							}
						]
					},
					{
						icon: "el-icon-bank-card",
						text: "审核管理",
						role_id: [3],
						routers: [{
								path: "/admin/auditor",
								text: "待审核列表",
								role_id: [3],
								is_refresh: true,
							},{
								path: "/admin/repair",
								text: "返修列表",
								role_id: [3],
								is_refresh: true,
							}
							// {
							// 	path: "/admin/auditor/notPass",
							// 	text: "未通过列表",
							// 	role_id: [3]
							// },
							// {
							// 	path: "/admin/auditor/passOrder",
							// 	text: "审核通过",
							// 	role_id: [3]
							// }
						]
					}
					// {
					//   icon: "el-icon-bank-card",
					//   text: "退款管理",
					//   routers: [
					//     {
					//       path: "未退款",
					//       text: "已退款"
					//     }
					//   ]
					// }
				],
				routerArr: [
					"/admin/login",
					"/admin/register",
					"/admin/prelogin",
					"/admin/agentCenter"
				], //不需要嵌套在本页面（即覆盖当前vue组件内容）的子路由及其组件
				tableData: [],
				isCollapse: false,
				waitOrder: '',
				is_improve: false,
				vipLogoClass: ''
			};
		},
		components: {
			editEmail,
			editPwd,
			rank,
			feedback
		},
		created() {
			this.fetchDate();
			if (this.$route.name == 'admin-agentImprove') {
				let params = {
					guard: 'agent'
				}
				this.getMyinfo(params)
			} else {
				this.getMyinfo()
			}
			this.getVipLogo()
		},
		computed : {
			is_adopt () {
				if (this.$store.state.roleInfo.is_adopt == '通过申请') {
					return 'success'
				} else if (this.$store.state.roleInfo.is_adopt == '驳回申请') {
					return 'danger'
				} else if (this.$store.state.roleInfo.is_adopt == '导师审核中') {
					return 'warning'
				}
			},
			// ...mapState(
			// 	'roleInfo'
			// )
			// 代理人未接单总数
			getRoleInfo () {
				return this.$store.state.roleInfo.waitOrder
			},
			// 我的订单总数
			getMyOrder () {
				return this.$store.state.roleInfo.myOrder
			},
			// 已完结订单总数
			getMyReply () {
				return this.$store.state.roleInfo.myReply
			},
			getReplyTotal () {
				return this.$store.state.roleInfo.reply_total
			},
			// 流程管理员 国知局后订单
			getTimeOut () {
				return this.$store.state.roleInfo.out_time_orders
			},
			getWaitSubmitTotal () {
				return this.$store.state.roleInfo.wait_submit_total
			},
			// 学生列表数量
			getStudentsNum () {
				return this.$store.state.roleInfo.studentListCount
			},
			// 老师审核列表数量
			getStudentsApply () {
				return this.$store.state.roleInfo.graduationCount
			},
			// 管理员审核列表数量
			getFinalApply () {
				return this.$store.state.roleInfo.twoGraduationCount
			},
			// 可开票总数
			getCanInvoiceTotal () {
				return this.$store.state.roleInfo.can_invoice_total
			},
			// 可确认缴款总数
			getCanNuclearMoneyTotal () {
				return this.$store.state.roleInfo.can_nuclear_money_total
			},
			// 可确认缴款总数
			getCan_refund_total () {
				return this.$store.state.roleInfo.can_refund_total
			},
			// 已开票数
			getInvoiced_total () {
				return this.$store.state.roleInfo.invoiced_total
			},
			// 待审核总数
			getVerifyTotal () {
				return this.$store.state.roleInfo.verify_total
			},
			// 返修案件总数
			getModifyTotal () {
				return this.$store.state.roleInfo.modify_total
			},
			getUnbind () {
				return this.$store.state.roleInfo.unbind_total
			},
			// 软著列表总数
			getSoftTotal () {
				return this.$store.state.roleInfo.soft_total
			},
			// 本月完成总数
			getMonTotal () {
				return this.$store.state.roleInfo.mon_total
			},
			// 导师审核徒弟案件总数
			getAuditedNum () {
				return this.$store.state.roleInfo.auditedNum
			},
			// 我的专利列表总数
			getPatentCount () {
				return this.$store.state.roleInfo.patentCount
			},
			// 自提案件总数
			getAgentOrderCount () {
				return this.$store.state.roleInfo.agentOrderCount
			},
			// 代理人提现待审核总数
			getDrawing_agent_check () {
				return this.$store.state.roleInfo.drawing_agent_check
			},
			// 用户提现待审核总数
			getDrawing_consumer_check () {
				return this.$store.state.roleInfo.drawing_consumer_check
			},
			// 活动待审核
			getActivity_check () {
				return this.$store.state.roleInfo.activity_check
			},
			// 代理人预注册待审核总数
			getPreregistration () {
				return this.$store.state.roleInfo.preregistration
			},
			// 代理人评分申诉
			getAgent_grades_appeal () {
				return this.$store.state.roleInfo.agent_grades_appeal
			},
			// 待回复列表
			getModify_total_message () {
				return this.$store.state.roleInfo.modify_total_message
			},
			// 扣款申诉待审核总数
			getAppealCount () {
				return this.$store.state.roleInfo.appealCount
			},
			// 发明人撤回缴费截图待审核总数
			getRevokePayImgCount () {
				return this.$store.state.roleInfo.revokePayImgCount
			},
			// 我的消息未读总数
			getNoRead () {
				return this.$store.state.roleInfo.noRead + this.$store.state.roleInfo.prNoRead
			},
			// 流程格式待审核总数
			getFinishFileFormatAudit () {
				return this.$store.state.roleInfo.finish_file_format_audit
			},
			// 反馈意见待审核总数
			getopinionCollectAudit () {
				return this.$store.state.roleInfo.opinion_collect_audit
			},

		},
		methods: {
			buyVip() {
				this.$router.replace({
					name: 'payment',
					query: {
						type: 'buyVip',
						vip: btoa('vip1'),
						from: this.$route.path
					}
				})
			},
			// 意见反馈
			feedback() {
				this.$refs['feedback'].show()
			},
			// 打开排行榜
			openLeaderboard() {
				this.$refs['rank'].show()
			},
			getVipLogo() {
				console.log(this.$store.state.user.vip)
				if (this.$store.state.user.vip == 0) {
					this.vipLogo = require("~/assets/img/vip0.svg")
				} else {
					this.vipLogo = require("~/assets/img/agent_vip.svg")
					// this.vipLevelPoints = 1
				}
			},
			apply() {
				// let start_time = new Date(this.$store.state.user.created_at).getTime()
				// let end_time = new Date().getTime()
				// let diff = Math.floor(Math.abs(end_time - start_time) / (24 * 3600 * 1000))
				// if (diff < 90) {
				// 	return this.$message({
				// 		type: 'error',
				// 		message: '您的入职时间未满90天，暂时无法申请出师'
				// 	})
				// }
				let message = ''
				if (this.$store.state.roleInfo.is_adopt == '未申请') {
					this.sumbitApply()
					return
				} else if (this.$store.state.roleInfo.is_adopt == '通过申请') {
					message = '您已经通过导师初审，请勿重复申请！'
				} else if (this.$store.state.roleInfo.is_adopt == '驳回申请') {
					this.sumbitApply()
					return
				} else if (this.$store.state.roleInfo.is_adopt == '导师审核中') {
					message = '您的申请导师正在审核，请勿重复申请！'
				}

				this.$alert(message, '提示', {
					confirmButtonText: '确定',
					center:true,
					callback: action => {
					}
				})
			},
			sumbitApply () {
				this.$confirm('确定提交出师申请吗？', '提示', {
					confirmButtonText: '确认',
					cancelButtonText: '取消',
					center: true,
				}).then(() => {
					this.$axios.post('/api/agent/submit_graduation').then(res => {
						if (res.data.code == 200) {
							this.$message({
								type: 'success',
								message: '出师申请提交成功，请耐心等待导师审核'
							})
							setTimeout(() => {
								this.$router.go(0)
							}, 1000)
						} else {
							this.$message({
								type: 'error',
								message: res.data.message
							})
						}
					})
				}).catch(() => {})
			},
			handleCommand(command) {
				if (command == "loginOut") {
					this.loginOut();
				}
				if (command == 'editEmail') {
					this.editEmail();
				}
				if (command == 'editPwd') {
					this.editPwd();
				}
			},
			loginOut() {
				this.$confirm("是否退出登录?", "提示", {
					confirmButtonText: "确定",
					cancelButtonText: "取消",
					center: true,
					type: "warning"
				})
				.then(() => {
					let url = this.$store.state.user.role_id == 2 ? '/order/login' : '/admin/login'
					if (this.$route.name.indexOf('agentImprove') > -1) {
						url = '/login?type=1'
					}
					this.$store.commit("delToken")
					this.$cookies.remove("token")
					this.$store.commit("delUser")
					this.$cookies.remove("user")
					if(process.client) {
						window.localStorage.setItem('auto_login', JSON.stringify(false))
					}
					this.$router.push({
						path: url
					});
				})
			},
			fetchDate() {
				//进入首页显示
				if (this.$route.path == "/admin") {
					if (this.$store.state.user.role_id == 1 || this.$store.state.user.role_id == 7) {
						this.$router.push("/admin/dataSum/agentData");
					} else if (this.$store.state.user.role_id == 2) {
						this.$router.push("/admin/order/pendingDisposal"); //代理人
					} else if (this.$store.state.user.role_id == 3) {
						this.$router.push("/admin/auditor"); //审核员
					} else if (this.$store.state.user.role_id == 4) {
						this.$router.push("/admin/dataSum/agentData"); //流程
					}
					if (this.$route.name == 'admin-agentImprove') {
						let params = {
							guard: 'agent'
						}
						this.getMyinfo(params)
					} else {
						this.getMyinfo()
					}
				}
				this.defaultActive = this.$route.path;
				//控制菜单
				this.filterRouter();
			},

			filterRouter() {
				let roleID = this.$store.state.user.role_id;
				if (roleID === 2 ) {
					this.routers[3].routers[0].text = '待接订单'

					let orderRouters = this.routers[3].routers
					for (let i = 0; i < orderRouters.length; i++) {

						if (orderRouters[i].text == '国知局前订单') {
							orderRouters.splice(i, 1)
						}
						if (orderRouters[i].text == '国知局后订单') {
							orderRouters.splice(i, 1)
						}
						// orderRouters[i].text == '国知局前订单' ? 	orderRouters.splice(i, 1) : continue
						// orderRouters[i].text == '国知局后订单' ? 	orderRouters.splice(i, 1) : continue
					}
					// if (	this.routers[3].routers.length > 4) {
						// this.routers[3].routers.splice(1, 2)
					// }

					// let myOrder = {
					// 	path: "/admin/order/myOreder",
					// 	text: "我的订单",
					// 	role_id: [2]
					// }
					let myAnswer = {
						path: "/admin/order/answer",
						text: "我的答复",
						role_id: [2]
					}
					// this.routers[3].routers.splice(1, 0, myOrder)
					// this.routers[3].routers.splice(2, 0, myAnswer)

					// if(this.routers[3].routers[this.routers[3].routers.length-1].path!="/admin/order/processed"){
					// 	console.log(this.routers[3])
					// 	this.routers[3].routers.push({
					// 		path: "/admin/order/processed",
					// 		text: "我的结算",
					// 		role_id: [1, 2, 4]
					// 	})
					// }

					// if(this.routers[3].routers[this.routers[3].routers.length-1].path!="/admin/order/answer"){
					// 	this.routers[3].routers.push(myAnswer)
					// }

					this.newRouter = [];
					const oldRouter = this.routers;
					if (this.$store.state.user.is_teacher != 1) {
						// oldRouter[3].routers.splice(oldRouter[3].routers.findIndex(v => v.text == '审核列表'), 1)
						// oldRouter[3].routers.findIndex(v => v.text == '审核列表')
						if (oldRouter[3].routers.findIndex(v => v.text == '审核列表') != -1) {
							oldRouter[3].routers.splice(oldRouter[3].routers.findIndex(v => v.text == '审核列表'), 1)
						}
						if (oldRouter.findIndex(v => v.text == '徒弟管理') != -1) {
							oldRouter.splice(oldRouter.findIndex(v => v.text == '徒弟管理'), 1)
						}
						// if (oldRouter.findIndex(v => v.text == '外部订单') != -1) {
						// 	oldRouter.splice(oldRouter.findIndex(v => v.text == '外部订单'), 1)
						// }
					}
					for (const i in oldRouter) {
						if (oldRouter[i].role_id.indexOf(roleID) != -1) {
							this.newRouter.push(oldRouter[i]);
						}
					}
				}else{
					//主要逻辑
					this.newRouter = [];
					const oldRouter = this.tempRouters;
					for (const i in oldRouter) {
						if (oldRouter[i].role_id.indexOf(roleID) != -1) {
							this.newRouter.push(oldRouter[i]);
						}
					}
				}
			},
			editEmail() {
				this.$refs.emailEdit.showDialog()
			},
			editPwd() {
				this.$refs.editPwd.showDialog()
			},
			refresh (data) {
				if (this.$route.path == data.path && data.is_refresh) {
					window.location.reload()
				}

				if(data.text == "待接订单") {
					if (this.$route.path == data.childrens[0].path && data.childrens[0].is_refresh) {
						window.location.reload()
					}
				}

			},
			gwm() {
				//水印,非管理员要设置
				if (this.$store.state.user.role_id != 1
					&& this.$route.path != '/admin/register'
					&& this.$route.path != '/admin/personalCenter/dstribution'
					&& this.$route.path != '/admin/personalCenter/myPurse'
					&& this.$route.path != '/admin/activityList/activityConfig'
					&& this.$route.path != '/admin/activityList/sysConfig'
					&& this.$route.path !='/admin/login'
					&& this.$route.path !='/admin/myNews/communication'
					&& this.$route.path !='/admin/myNews/notice'
					&& this.$route.path !='/user/apply'
					&& this.$route.path != '/admin/agentImprove'
					&& this.$route.path != '/order/login') {
					let that = this;
					let gwm = require('gwm');
					gwm.creation({
						'txt': that.$store.state.user.name,
						'container': '.el-table', //#gwm
						'fontSize': 40
					})
				}
			},
			async getMyinfo (params) {
				let myInfo = await getMyInfo(this.$axios, params);
				if (myInfo.data.status == 'success') {
					this.$store.commit("setRoleInfo",myInfo.data.data)
					this.$store.commit("setUser",myInfo.data.data);
				}
			}
		},
		mounted() {
			this.gwm();
		},
		updated() {
			let that = this;
			setTimeout(function() {
				that.gwm();
			}, 500)
		},
		watch: {
			// 如果路由有变化，会再次执行该方法
			$route: "fetchDate",
			'$store.state.user.vip': {
				handler: function (val) {
					if (val == 0) {
						this.vipLogoClass = 'icon iconfont icon-VIP'
					} else {
						this.vipLogoClass = 'icon iconfont icon-VIP font_red'
					}
				},
				immediate: true,
				// deep: true
			}
		}
	};
</script>
<style lang="less" scope>
	#admin {
		.el-card{
			border-width: 0 !important;
		}
		//要显示水印。必须去掉背景色
		#gwm {
			.el-table {
				//浮动元素，一般是操作列。设置不透明。
				.el-table__fixed-right {
					background: white !important;
				}

				background: transparent;

				table {
					background: transparent;
				}

				tr {
					background: transparent;

					th {
						background: transparent;
					}
				}
			}
		}

		height: 100%;

		.el-container {
			min-height: 100vh;
		}

		.el-menu-vertical-demo:not(.el-menu--collapse) {
			width: 201px;
			min-height: 400px;
		}

		.el-menu-vertical-demo:not(.el-menu--collapse) .el-submenu {
			width: 200px;
		}

		.title-name {
			// text-align: center;
			font-size: 16px;
		}

		.main-heads {
			height: 60px;
			line-height: 60px;
			border-bottom: 1px solid #f6f6f6;
			padding-right: 30px;
			position: relative;
		}

		.btn-show {
			float: left;
			margin-top: 30px;
			transform: translateY(-50%);
		}

		.el-pagination {
			margin-top: 20px;
		}

		.el-main {
			height: 100%;
			// height: 500px;
		}

		.el-main .el-table {
			min-height: 500px;
		}

		.el-button--small,
		.el-button--small.is-round {
			padding: 6px 8px;
		}

		.el-table td,
		.el-table th {
			padding: 4px 0;
		}

		.el-table--scrollable-x .el-table__body-wrapper {
			min-height: 456px;
		}

		/* 已完结案件数 */
		.end_orderNum {
			width: 200px;
			float: left;
			margin-right: 10px;
			margin-bottom: 10px;
		}

		// .el-table__fixed-body-wrapper {
		// 	top: 43px !important;
		// }

		.el-table {
			width: 99.9% !important;
		}

		/* .el-table .cell {
		  height: 30px !important;
		  line-height: 30px;
		} */
		.down-execel {
			display: block;
			height: 40px;
			line-height: 40px;
			color: #333333;
			font-size: 14px;
			float: right;
			margin-right: 20px;
		}

		.logo-box {
			height: 60px;
			background: white;
			display: flex;
			justify-content: center;
			align-items: center;

			.logo {
				height: 50px !important;
				/*no*/
				margin: 5px;
				box-sizing: border-box;
			}
		}

		.el-badge__content {
			border: 1px solid #545c64;
			line-height: 16px;
		}
		.el-badge__content.is-fixed {
			top: 13px;
			right: 0px;
			padding: 0 9px;
		}
		.font_red {
      color: #d81e06;
    }
	}
	.silder-bar-wrap {
		background-color: rgb(84, 92, 100);
		position: relative;
		// padding-bottom: 65px;
		padding-bottom: 230px;
		.el-menu {
			height: 100%;
		}

		.welcome {
			position: absolute;
			bottom: 20px;
			width: 100%;
			color: #fff;
			font-size: 16px;
			font-weight: 600;
			justify-content: center;
			text-align: center;
			> div {
				align-items: center;
				display: flex;
				justify-content: center;
			}
			img {
				display: block;
				width: 25px;
				margin-right: 5px;
			}
			span {
				line-height: 25px;
				overflow:hidden; //超出的文本隐藏
				text-overflow:ellipsis; //溢出用省略号显示
				white-space:nowrap; //溢出不换行
			}
			.buyVip {
				span {
					line-height: 1;
				}
			}

		}
		.vip {
			bottom: 80px;
			img {
				display: inline-block;
				width: 20;
			}
		}
	}
	.el-header {
		.rank {
			height: 100%;
			line-height: 60px;
			background: #ecf5ff;
			padding: 0 12px;
		}
	}


	.teacher_tips {
		.is-fixed {
			top: 13px;
			right: 0px;
			padding: 0 !important;
		}
		.is-dot {
			height: 13px;
			width: 13px;
			padding: 0;
			right: 0;
			border-radius: 50%;
		}
	}
	.admin_icon {
		vertical-align: middle;
    margin-right: 5px;
    // width: 24px;
    // text-align: center;
		font-size: 26px;
		// display: inline-block;
		// line-height: 1;
	}
</style>
